<%@page import="com.zkingsoft.pojo.ElementTypeFactory"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	//获取元素类型
	pageContext.setAttribute("list", ElementTypeFactory.getElements());
%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<LINK rel="Bookmark" href="../images/favicon.ico">


<link rel="stylesheet"
	href="${path }/resource/plugin/kindeditor/themes/default/default.css" />
<link rel="stylesheet"
	href="${path }/resource/plugin/kindeditor/plugins/code/prettify.css" />
<script src="${path }/resource/plugin/kindeditor/kindeditor.js"></script>
<script src="${path }/resource/plugin/kindeditor/lang/zh_CN.js"></script>
<script
	src="${path }/resource/plugin/kindeditor/plugins/code/prettify.js"></script>
<!--[if lt IE 9]>
<script type="text/javascript" src="${path }/resource/plugin/hui/lib/html5.js"></script>
<script type="text/javascript" src="${path }/resource/plugin/hui/lib/respond.min.js"></script>
<script type="text/javascript" src="${path }/resource/plugin/hui/lib/PIE_IE678.js"></script>
<![endif]-->

<!-- 本框架基本脚本和样式 -->
<script type="text/javascript"
	src="${path }/resource/js/jquery-2.1.4.min.js"></script>
<script type="text/javascript"
	src="${path }/resource/js/systools/EXBase.js"></script>

<!--[if IE 6]>
<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>

<![endif]-->
<title>移动导航列表</title>
</head>
<body style="height: 100%; overflow: hidden;">

	<form class="form form-horizontal" id="dataform"
		action="admin/nav/addOrModify" onsubmit="javascripr:return false;">
		<input type="hidden" value="2" name="plat">
		<div class="row cl">
			<label class="form-label col-2">父级移动导航</label>
			<div class="formControls col-3">
				<select class="select select-box" size="1" name="parentId"
					id="parentId">
				</select>
			</div>
			<div class="col-1">
				<span class="Validform_checktip"></span>
			</div>
			<label class="form-label col-2">移动导航名称</label>
			<div class="formControls col-3">
				<input name="name" type="text" class="input-text " datatype="*1-50">
			</div>
			<div class="col-1">
				<span class="Validform_checktip"></span>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-2">类型</label>
			<div class="formControls col-3">
				<select class="select select-box" size="1" name="type" id="type"
					onchange="selectType(this)">
					<option value="self">自定义</option>
					<c:forEach items="${list }" var="item">
						<option value='${item.value }'>${item.name }</option>
					</c:forEach>
				</select>
			</div>
			<div class="col-1">
				<span class="Validform_checktip"></span>
			</div>
			<label class="form-label col-2">url</label>
			<div class="formControls col-3" id="url">
				<input datatype="*" ignore="ignore"name="url" type="text" class="input-text ">
			</div>
			<div class="col-1">
				<span class="Validform_checktip"></span>
			</div>
		</div>
		<div class="row cl">

			<label class="form-label col-2">描述</label>
			<div class="formControls col-9">
				<input name="description" datatype="*" type="text"
					class="input-text " value="">
			</div>
			<div class="col-1">
				<span class="Validform_checktip"></span>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-2">展示图片</label>

			<div class="formControls col-9">
				<span class="btn-upload form-group"> <input
					onclick="EXCommon.chooesFile()"
					class="input-text upload-url radius" type="text" id="showFileName"
					readonly> <a onclick="EXCommon.chooesFile()"
					class="btn btn-primary radius"><i class="fa fa-cloud-upload"></i>
						浏览文件</a>
				</span> <input type="button" class='btn btn-primary radius'
					onclick="EXCommon.upFile()" value="上传"> <a
					id="selectInServices" class="btn btn-primary radius"><i
					class="fa fa-cloud"></i> 远程图库</a>
			</div>
		</div>
		<div class="row cl">
			<div class="col-1"></div>
			<div class="col-md-offset-1 formControls col-9">
					<input type="hidden" name="inco" id="hiddenImg" />
					<img width="150" id='img_1' style="display: none" />
			</div>
		</div>
		<div class="row cl mt-40">
			<div class="col-12 text-c">
				<a href="javascript:;" onclick="EXForm.submit()"
					class="btn btn-success radius">保存</a>&nbsp;&nbsp;&nbsp;&nbsp; <input
					type="reset" class="btn btn-danger radius" value="重置" />
			</div>
		</div>
	</form>

	<form class="form form-horizontal" method="post" style="display: none;"
		enctype="multipart/form-data" target="blankFrame"
		action="${path }/resource/plugin/kindeditor/upload_json.jsp?dir=image&flag=img_1&hiddenImg=hiddenImg">
		<input id="fileText" type="file" multiple name="file-1"
			onchange="EXCommon.selectFile('#showFileName')" /> <input
			type="submit" id="submitBtn"
			onclick="EXCommon.upolad('img_1','file_1')" />
	</form>
	<iframe src="" name="blankFrame" id="blankFrame"
		style="height: 100px; width: 100px; display: none;"> </iframe>


	<script type="text/javascript">
		$(function() {
			EXForm.initForm({
				refresh : function() {
					parent.initFunctionList();
				}
			});
			initFunctionList();
			EXUI.openServiceImgSpace(function(url) {
				$("#img_1").attr("src", url).show();
				$("#hiddenImg").val(url);
			}, "#selectInServices");
		});

		/**
		 * 初始化移动导航列表
		 */
		function initFunctionList() {
			$.AjaxProxy({
				p:{plat:2},
				a : false,
				c : false
			}).invoke("admin/nav/all", function(loj) {
				$("#parentId").createSelectTree(loj.attr("result").dataList, {
					append : true
				});
			});

		}

		function showIcon() {
			layer.open({
				type : 2,
				title : "选择图标",
				area : [ '80%', '80%' ],
				fix : true, // 不固定
				maxmin : true,
				content : '${path}/common/redirect/icons'
			});
		}

		/**
		当用户改变导航类型的时候联动url控件的改变
	 */
	function selectType(select) {
		var node = $("#url");
		var type = "";
		if (select.value == 'article') {
			//文章
			type = "article";
		} else if (select.value == 'product') {
			//产品
			type = "product";
		} else if (select.value == 'album') {
			//相册
			type = "album";
		} else if (select.value == 'vodoe') {
			//视频
			type = "vidoe";
		} else if (select.value == 'self') {
			node
					.html('<input datatype="url" name="url" type="text" class="input-text "> ');
			return;
		}
		node
				.html('<select class="select select-box" size="1" name="url" id="urlselect"> </select> ');
		$.AjaxProxy({
			a : false,
			c : false
		}).invoke("admin/nav/getCate?type=" + type, function(loj) {
			$("#urlselect").createSelectTree(loj.attr("result").dataList, {
				append : true
			});
		});
	}
	</script>
</body>
</html>